using Cysharp.Threading.Tasks;
using UnityEngine;

namespace FastDev
{
    public class ResLoader : IResLoad, IResUnload
    {
        public AssetBundle LoadAssetBundle(string path)
        {
            Debug.Log("Load AssetBundle:" + path);
            return AssetBundle.LoadFromFile(path);
        }

        public async UniTask<AssetBundle> LoadAssetBundleAsync(string path)
        {
            Debug.Log("Load AssetBundle:" + path);
            AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(path);
            await request;
            return request.assetBundle;
        }

        public void UnloadAssetBundle(AssetBundle assetBundle, bool unloadAll)
        {
            assetBundle.Unload(unloadAll);
        }
    }
}
